package com.gitee.xhs.saveAndModifyingPointWriter.keyedState.listState;

import com.gitee.xhs.keyedState.listState.ListStateConstant;
import com.gitee.xhs.sampleRecod.transactionRecord.Transaction;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.state.api.functions.KeyedStateBootstrapFunction;

/**
 * @author BigHead
 * @date 2022/7/12 10:56
 * @description ListStateNewSavePointsFunction
 */
public class ListStateNewSavePointsFunction extends KeyedStateBootstrapFunction<Long, Transaction> {

    private transient ListState<Transaction> listState;

    @Override
    public void open(Configuration parameters) throws Exception {
        listState = getRuntimeContext().getListState(
                ListStateConstant.LIST_STATE_DESCRIPTOR
        );
    }

    @Override
    public void processElement(Transaction value, KeyedStateBootstrapFunction<Long, Transaction>.Context ctx) throws Exception {
        listState.add(value);
    }
}
